<input type="hidden" name="address_id" value="<?php echo isset($address->address_id) ? $address->address_id :'';?>" />
<div class="newconfirm">
    <div class="expressaddress">
        <?php $this->load->view('tourism/order/order_address');?>
    </div>
    <?php $total = 0; ?>
    <?php $count = 0; ?>
    <?php $totalSwim = 0; ?>
    <?php $totalTranspost = 0;?>
    <?php $bonus = $actualBonus;?>
    <?php foreach ($goodsData as $item):?>
    <?php $totalShop = $item['transport_cost'];$totalTranspost += $item['transport_cost'];?>
    <?php $countShop = 0;?>
    <div class="goods-shop">
        <div class="shop-header"><?php echo $item['alias_name'];?></div>
        <div class="goods-group">
            <div class="goods-group-item">
                <div class="o-item am-cf">
                    <?php foreach($item['goodsInfo'] as $value):?>
                    <?php $totalShop = bcadd($totalShop, bcmul($value->goods_num, $value->shop_price, 2), 2);?>
                    <?php $countShop += $value->goods_num;?>
                    <?php if ( $bonus >= bcmul($value->goods_num,$value->swim) ) :?>
                    <?php
                          $totalSwim += bcmul($value->goods_num,$value->swim);
                          $bonus -= $totalSwim;
                    ?>
                    <?php endif;?>
                    <div class="item-detail am-cf">
                           <div class="am-cf">
                            <div class="item-img">
                                <a href="<?php echo site_url('tourism/goods/info/'.$value->goods_attr_id);?>">
                                    <img class="lazy" src="<?php echo $this->config->show_image_url($value->images, '200-200');?>" data-src-checked="true">
                                </a>
                            </div>
                            <div class="item-info">
                                <a href="<?php echo site_url('tourism/goods/info/'.$value->goods_attr_id);?>" title="<?php echo $value->goods_name;?>">
                                    <h3 class="title"><?php echo $value->goods_name;?></h3>
                                    <?php if (!empty($value->attribute_value)): ?>
                                        <?php $attribute = explode(',',$value->attribute_value);?>
                                        <div class="sku">
                                            <p>
                                                <?php foreach ($attribute as $val): ?>
                                                    <span><?php echo $val;?></span>
                                                <?php endforeach; ?>
                                            </p>
                                        </div>
                                    <?php endif;?>
                                </a>
                                <div class="pay am-cf">
                                    <div class="pay-price">
                                        <div class="price">
                                            <p class="o-t-price">
                                                <span><?php echo $value->shop_price;?></span>
                                            </p>
                                        </div>
                                        <div class="originPrice">
                                            <p><del>￥<?php echo $value->market_price;?></del></p>
                                        </div>
                                    </div>
                                    <div class="quantity">
                                        <p><span>x</span><span><?php echo $value->goods_num;?></span></p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php endforeach ?>
                    <div class="order-detail">
                        <div class="block-item order-express">
                            <p>配送方式<span class="pull-right">快递配送（<span class="order-express-money"><?php if ($item['transport_cost'] > 0): ?><?php echo $item['transport_cost'];?>元<?php else:?>免邮<?php endif;?></span>）</span></p>
                        </div>
                        <div class="block-item order-message">
                            <span>买家留言：</span>
                            <textarea class="msg-container" name="message[<?php echo $item['uid'];?>]" placeholder="选填，请填写您与卖家达成一致的要求"></textarea>
                            <input type="hidden" name="vanguard[<?php echo $item['uid'];?>]" value="" />
                        </div>
                        <div class="statistics">
                            <span>共<span class="num"><?php echo $countShop; ?></span>件商品</span>
                            <span>合计：<span class="red money">￥<span class="totleMoney"><?php echo $totalShop;?></span></span></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php $total += $totalShop;?>
    <?php $count += $countShop;?>
    <?php endforeach;?>
    
    <?php if($totalSwim>0):?>
    <div class="discount">
        可用<?php echo $totalSwim;?>枚积分抵扣  ￥<span class="dikou"><?php echo $totalSwim;?></span>
        <div class="am-check">
            <span class="check-wrapper <?php if(!empty($swim)):?>active<?php endif;?>"></span>
        </div>
    </div>
    <?php endif;?>
    <input type="hidden" name="swim" value="<?php echo  !empty($swim) ? $swim : '0';?>" class="swim"/>
</div>
<div class="newconfirm-last am-cf">
    <div class="newconfirm-last-right">
        <div class="total">
            <p>合计：<span class="price">￥<span id="totalPrice"><?php echo empty($swim) ? bcsub($total,0,2) : bcsub($total,$totalSwim,2);?></span></span></p>
            <p class="gray">含运费：￥<span id="expressMoney"><?php echo $totalTranspost;?></span></p>
        </div>
        <button type="submit" class="am-btn am-btn-danger active">结算(<span id="itemsCount"><?php echo $count;?></span>件)</button>
    </div>
</div>
<script type="text/javascript">
$('.newconfirm').on('click','.discount', function(e){  //U币的抵扣
    var check = $(this).find('.check-wrapper');
    var swimVal = $('input[name=swim]');
    check.toggleClass('active');
    check.is('.active') ? swimVal.val(1) : swimVal.val(0);
    var swim = swimVal.val();
    var address_id = $('input[name=address_id]').val();
    ajaxOrderContent(address_id, swim);
})
</script>